﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using ERP_RORZE_SYSTEM;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using ERP_RORZE_PERMISSION.Base;
using ERP_RORZE_PERMISSION.Forms;

namespace ERP_RORZE_DLL.Business
{
    public partial class BusinessLeftPannel : UserControl
    {
        private Permission role;

        public BusinessLeftPannel()
        {
            InitializeComponent();
            this.role = new Permission();
            ShowHideLink();
        }

        ///////////////////////////////////////////
        /// Check role
        ///////////////////////////////////////////
        private void ShowHideLink()
        {
            if (role.Is_Login())
            {
                //if (role.HasNotRight(PermissionConstants.Functions.Tab.System))
                //    systemTab.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Business.ImportQuotation))
                    navImportQuotation.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Business.ExportQuotation))
                    navExportQuotation.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Business.ExportRobotQuotation))
                    navRobotQuotation.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Business.ExportPartQuotation))
                    navPartQuotation.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Business.Clearance))
                    navClearance.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Business.Clearance_Order))
                    navOrderClearance.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Business.PurchaseOrder))
                    navPurchaseOrder.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Business.PurchaseInformation))
                    navPurchaseInfomation.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Business.MasterPO))
                    navMasterPO.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Business.MasterPODetails))
                    navMasterPODetails.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Business.PartReceive))
                    navPartReceive.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Business.PartMistake))
                    navPartMistake.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Business.StoreInputEstimate))
                    navStoreInputEstimate.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Business.ExportPlan))
                    navExportPlan.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Business.IQLastRemain))
                    navIQLastRemain.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Business.RZCode))
                    navRZCode.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Business.RZConsumption))
                    navRZConsumption.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Business.ConsumptionExportCheck))
                    navConsumptionExCheck.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Business.IQRealTime))
                    navIQRealTime.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Business.Forecast))
                {
                    navMasterPlan.Visible = false;
                    navMonthlyEnding.Visible = false;
                }

                if (role.HasNotRight(PermissionConstants.Functions.Business.POReport))
                    rptPOCover.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Business.MasterPOReport))
                    rptMasterPOCover.Visible = false;
            }
            else
            {
                foreach (Control c in this.Controls)
                {
                    if (c is DevExpress.XtraNavBar.NavBarControl)
                    {
                        foreach (DevExpress.XtraNavBar.NavBarItem sub_c in c.Controls)
                        {
                            ((DevExpress.XtraNavBar.NavBarItem)sub_c).Enabled = false;
                        }
                    }
                }
            }
        }
    }
}
